package org.rcy.framework.thrift.struct;

import org.rcy.framework.thrift.metadata.FieldIdEnum;
import org.rcy.framework.thrift.metadata.MethodMetaData;

import java.util.Set;

/**
 * TBase的参数实现
 * 
 * @author zhouree
 */
public class ArgsStruct extends AbstractStruct {

	private static final long serialVersionUID = 1L;

	public ArgsStruct(MethodMetaData methodMetaData, Object... values) {
		super(methodMetaData.getParamsMetaMap());

		Set<FieldIdEnum> fields = methodMetaData.getParamsMetaMap().keySet();
		for (FieldIdEnum field : fields) {
			int index = field.getThriftFieldId();
			if (values != null && values.length >= index) {
				Object value = values[index - 1];
				addValue(field, value);
			}
		}
	}

}
